clearuse "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\EugMar11.dta", clear*ongoing years included, but not as Y eventsdrop if year <1947merge 1:1 ccode1 ccode2 year using "C:\Users\mmousseau\Documents\Working Papers Data Sets\distance.dta"
drop if  _merge==2drop  _mergereplace 	tpop_1		=. if tpop_1	 	==-9replace 	tpop_2		=. if tpop_2	 	==-9replace 	energy_1	=. if energy_1	==-9replace 	energy_2	=. if energy_2	==-9replace 	cap_1		=. if cap_1	 	==-9replace 	cap_2		=. if cap_2	 	==-9replace 	mzfatald	=. if mzfatald	==-9replace 	polity21	=. if polity21	==-99replace 	polity22	=. if polity22	==-99g cpl = cap_1 if cap_1 < cap_2 & cap_1~=. & cap_2~=.replace cpl = cap_2 if cap_2 <= cap_1 & cap_1~=. & cap_2~=.g cph = cap_1 if cap_1 > cap_2 & cap_1~=. & cap_2~=.replace cph = cap_2 if cap_2 >= cap_1 & cap_1~=. & cap_2~=.g lncprt=ln(cph/cpl) if cph~=. & cpl~=.drop cap_1 cap_2 cpl cphlabel variable lncprt "Relative capability"g mjpw=0replace mjpw=1 if majpow1==1 | majpow2==1drop majpow1 majpow2label variable mjpw "Major power"
g cntg=0 replace cntg = 1 if contig <= 5drop contiglabel variable cntg "Contiguity"
g dist=ln(distance) if distance~=.drop distancelabel variable dist "Distance"
g edv1= energy_1/ tpop_1g edv2= energy_2/ tpop_2g edvl= ln(edv1+1) if edv1 ~=. & edv2 ~=.replace edvl= ln(edv2+1) if edv2<edv1 & edv1 ~=. & edv2 ~=.drop energy_1 energy_2 label variable edvl "WealthL"sort ccode1 ccode2 yearg mzfmid=0 if mzmid~=. & mzfatald~=.replace  mzfmid=1 if  mzfatald>=1 & mzmid==1 & mzfatald~=. & mzmid~=.gen double ID= (1000000*ccode1)+ccode2g mzfmidl = mzfmid[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1g mzmidl = mzmid[_n+1] if ID==ID[_n+1] & year[_n+1]==year+1sort IDbtscs mzfmidl year ID, g(fpceyrs) nspline(3)rename  _spline1  fspl1rename  _spline2  fspl2rename  _spline3  fspl3btscs mzmidl year ID, g(apceyrs) nspline(3)rename  _spline1  aspl1rename  _spline2  aspl2rename  _spline3  aspl3rename mzmidl mzamidldrop mzfmid upop_2 irst_2  milex_2 milper_2 upop_1 irst_1  milex_1 milper_1 mzongo mzongonm mzmid mzmidnm mzhost1 mzhost2 mzkeynum mzfatald mzpceyrsg dyadid=ccode1*10000+ccode2drop if year <1960save "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", replace
use "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", clear
merge 1:1 year dyadid using "C:\Users\mmousseau\Documents\Working Papers Data Sets\Gleditsch Trade.dta"
drop if  _merge==2
drop  _merge

merge 1:1 dyadid year using "C:\Users\mmousseau\Documents\Working Papers Data Sets\Gartzke.dta"
drop  _merge

sort ccode2 year
merge m:1 ccode2 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\PWT_Gleditsch2.dta"
drop if  _merge==2
drop  _merge

merge m:1 ccode2 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\McDon_2.dta"
drop if  _merge==2
drop  _merge

sort ccode1 year
merge m:1 ccode1 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\PWT_Gleditsch1.dta"
drop if  _merge==2
drop  _merge
merge m:1 ccode1 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\McDon_1.dta"
drop if  _merge==2
drop  _merge

sort  ccode2 year
merge m:1 ccode2 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\CINE 2011.2.15 ccode2.dta"
drop if  _merge==2
drop  _merge
sort  ccode1 year
merge m:1 ccode1 year using "C:\Users\mmousseau\Documents\Ifolder3\Ifolder\Working Papers\Data\CINE 2011.2.15 ccode1.dta"
drop if  _merge==2
drop  _merge


merge 1:1 ccode1 ccode2 year using "C:\Users\mmousseau\Documents\Working Papers Data Sets\Political Dissimilarity Werner.dta"
drop if  _merge==2
drop  _merge

save "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", replace
use "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", clear
replace 	capopenl	=. if capopenl	==-9replace 	pub1	=. if pub1		==-9replace 	pub2	=. if pub2		==-9g CIEl= CIE1 if CIE1~=. & CIE2~=.replace CIEl= CIE2 if CIE1> CIE2 & CIE1~=. & CIE2~=.label variable CIEl "CIEL"
g bCIE=0 if CIEd1~=. | CIEd2~=.replace bCIE=1 if CIEd1==1 & CIEd2==1label variable bCIE "CIEBinary"
g dml=polity21 if polity21~=. & polity22~=.replace dml= polity22 if polity21> polity22 & polity21~=. & polity22~=.g dmh=polity21 if polity21~=. & polity22~=.replace dmh= polity22 if polity21< polity22 & polity21~=. & polity22~=.g dmdist = dmh-dml if dmh~=. & dml~=.*drop polity21 polity22 label variable dml "DemocracyL"
label variable dmdist "Regime Difference"
g bdm=0 if dml~=.replace bdm=1 if dml >=7 & dml~=.label variable bdm "DemocracyBinary6"
g h10dm=0 if  dml~=.replace h10dm=1 if  dml==10 & dml~=.replace h10dm=. if  dml==.label variable h10dm "DemocracyBinary10"
gen dml2=dml+10
gen dmlsq=dml2^2
label variable dmlsq "DemocracyL^2"g dvl= ln(rgdp96pc1) if rgdp96pc1 ~=. & rgdp96pc2 ~=.replace dvl= ln(rgdp96pc2) if rgdp96pc2<rgdp96pc1 & rgdp96pc1 ~=. & rgdp96pc2 ~=.drop rgdp96pc1 rgdp96pc2
g dpl=dp1*100 if dp1~=. & dp2~=.replace dpl= dp2*100 if dp1> dp2 & dp1~=. & dp2~=.drop dp1 dp2label variable dpl "TradeL"
g pubh=pub1 if pub1~=. & pub2~=.replace pubh= pub2 if pub2> pub1 & pub1~=. & pub2~=.drop pub1 pub2label variable pubh "PublicH"
sort dyadidgen capopenl2=capopenlreplace capopenl2=0 if (capopenl==. & year>=1966 & year<1993)labe variable capopenl  "CAPOPENL (Gartzke 2007)"labe variable capopenl2 "CAPOPENL (Gartzke & Hewitt 2010)"by dyadid: ipolate capopenl year, gen(capopenl_ipol)gen capopenl_ipol2=capopenl_ipolreplace capopenl_ipol2=0 if (capopenl_ipol==. & year>=1966 & year<=1992)labe variable capopenl_ipol2 "Capital OpennessL"g misscpl=0replace misscpl=1 if capopenl==. replace misscpl = . if year <1966replace misscpl = . if year > 1992tab misscpl mzfmidlg incrrctmiss=0replace incrrctmiss =1 if capopenl ==. & capopenl_ipol~=.replace incrrctmiss = . if year <1966replace incrrctmiss = . if year > 1992tab incrrctmiss mzfmidl
sum year if year >1960

drop if CIEl==.
save "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", replace
*********************************************************************************************************
******************************************ANALYSES*******************************************************
*********************************************************************************************************
clearuse "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta", clear
************************************************************************************************Table 1: Contract Intensive Economy, Democracy, and Militarized Interstate Conflict*****
********************************************************************************************global fmcontrols lncprt mjpw cntg dist numstate fpceyrs fspl1 fspl2 fspl3
global amcontrols lncprt mjpw cntg dist numstate apceyrs aspl1 aspl2 aspl3quietly {
eststo cleareststo: logit mzfmidl 		dml 					   $fmcontrols, cl(ID) nologeststo: logit mzfmidl CIEl 	dml 					   $fmcontrols, cl(ID) nologeststo: logit mzfmidl CIEl 	dml  			 	PolDis $fmcontrols				, cl(ID) nologeststo: logit mzfmidl CIEl  	bdm 		 	PolDis $fmcontrols				, cl(ID) nologeststo: logit mzamidl CIEl 			h10dm    	PolDis $amcontrols , cl(ID) nologeststo: logit mzfmidl CIEl 			dmlsq 		PolDis $fmcontrols , cl(ID) nolog
}
esttab, b(2) se(2) replace label star(t 0.10 * 0.05 ** 0.01 *** 0.001)  order(CIEl dml bdm h10dm dmlsq PolDis  $fmcontrols	$amcontrol) scalars("ll Log lik.") pr2 varwidth(25) modelwidth(8)

************************************************************************************************Table A1: Contract Intensive Economy, Democracy, and Militarized Interstate Conflict****
********************************************************************************************
quietly {
eststo cleareststo: logit mzamidl CIEl 	dml  			PolDis 	$amcontrols , cl(ID) nologeststo: logit mzamidl CIEl 		bdm 		PolDis 	$amcontrols , cl(ID) nolog
eststo: logit mzamidl CIEl dmlsq 			PolDis 	$amcontrols , cl(ID) nolog}

esttab, b(2) se(2) replace label star(t 0.10 * 0.05 ** 0.01 *** 0.001)  order(CIEl dml bdm dmlsq PolDis $amcontrol) scalars("ll Log lik.") pr2 varwidth(25) modelwidth(8)

************************************************************************************************************Table 2: Tests for Competing Theories of Capitalist Peace ******************
********************************************************************************************quietly {
eststo cleareststo: logit mzfmidl CIEl edvl  							PolDis $fmcontrols		, cl(ID) nologeststo: logit mzfmidl CIEl 		dpl  						PolDis $fmcontrols		, cl(ID) nologeststo: logit mzfmidl CIEl 			capopenl_ipol2 			PolDis $fmcontrols		, cl(ID) nologeststo: logit mzfmidl CIEl 							pubh 	PolDis $fmcontrols		, cl(ID) nolog}
esttab, b(2) se(2) replace label star(t 0.10 * 0.05 ** 0.01 *** 0.001)  order(CIEl edvl dpl capopenl_ipol2 pubh PolDis $fmcontrols) scalars("ll Log lik.") pr2 varwidth(25) modelwidth(8)


***********************************************************************************************************Table A2: Tests for Competing Theories of Capitalist Peace ******************
********************************************************************************************quietly {
eststo cleareststo: logit mzfmidl  edvl  					PolDis  $fmcontrols		, cl(ID) nologeststo: logit mzfmidl  		dpl  				PolDis  $fmcontrols		, cl(ID) nologeststo: logit mzfmidl  			capopenl_ipol2 	PolDis  $fmcontrols		, cl(ID) nologeststo: logit mzfmidl  					pubh 	PolDis  $fmcontrols		, cl(ID) nolog}
esttab, b(2) se(2) replace label star(t 0.10 * 0.05 ** 0.01 *** 0.001)  order(edvl dpl capopenl_ipol2 pubh PolDis $fmcontrols) scalars("ll Log lik.") pr2 varwidth(25) modelwidth(8)

********************************************************************************************
***************Table A3: Tests for Competing Theories of Capitalist Peace ******************
********************************************************************************************
quietly {
eststo clear
eststo: logit mzfmidl CIEl dvl  			PolDis $fmcontrols		, cl(ID) nolog
eststo: logit mzamidl CIEl dvl  			PolDis $amcontrols		, cl(ID) nolog
eststo: logit mzamidl CIEl edvl  			PolDis $amcontrols		, cl(ID) nolog
eststo: logit mzamidl CIEl dpl  			PolDis $amcontrols		, cl(ID) nolog
eststo: logit mzamidl CIEl capopenl_ipol2 	PolDis $amcontrols		, cl(ID) nolog
eststo: logit mzamidl CIEl pubh 		 	PolDis $amcontrols		, cl(ID) nolog
}
esttab, b(2) se(2) replace label star(t 0.10 * 0.05 ** 0.01 *** 0.001)  order(CIEl dvl edvl dpl capopenl_ipol2 pubh PolDis $fmcontrols $amcontrols) scalars("ll Log lik.") pr2 varwidth(25) modelwidth(8)



**********************************************************************
***************TESTING FOR MULTICOLLINEARITY**************************
**********************************************************************
tab bCIE if bdm==1
corr CIEl dml if mzfmidl~=.  
reg mzfmidl 	CIEl 	dml  						$fmcontrols
vif
reg mzfmidl CIEl edvl  								$fmcontrols
vif
reg mzfmidl CIEl 		dpl  						$fmcontrols
vif
reg mzfmidl CIEl 				capopenl_ipol2 		$fmcontrols
vif
reg mzfmidl CIEl 							pubh 	$fmcontrols
vif

***********************************************************************
*******************QUANTITIES OF INTEREST******************************
***********************************************************************
clear
use "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta"
estsimp logit mzfmidl CIEl lncprt mjpw cntg dist numstate fpceyrs fspl1 fspl2 fspl3	, cl(ID) nolog
setx CIEl median lncprt median mjpw 0 cntg 1 dist min numstate median fpceyrs 0 fspl1 0 fspl2 0 fspl3 0

simqi, fd(prval(1)) changex(CIEl p5 p95)
simqi, fd(prval(1)) changex(lncprt p5 p95)
simqi, fd(prval(1)) changex(mjpw 0 1)
simqi, fd(prval(1)) changex(cntg 0 1)
simqi, fd(prval(1)) changex(dist p5 p95)
simqi, fd(prval(1)) changex(fpceyrs p5 p95)


******************************
****Table 2, Model 2**********
******************************
clear
use "C:\Users\mmousseau\Documents\Working Papers Data Sets\Cap Peace\DPUNRAV.dta"
global fmcontrols PolDis lncprt mjpw cntg dist numstate fpceyrs fspl1 fspl2 fspl3
estsimp logit mzfmidl CIEl 		dpl  						$fmcontrols		, cl(ID) nolog
setx CIEl median PolDis median dpl median lncprt median mjpw 0 cntg 1 dist min numstate median fpceyrs 0 fspl1 0 fspl2 0 fspl3 0

simqi, fd(prval(1)) changex(CIEl p5 p95)
simqi, fd(prval(1)) changex(dpl p5 p95)
simqi, fd(prval(1)) changex(PolDis p5 p95)
simqi, fd(prval(1)) changex(lncprt p5 p95)
simqi, fd(prval(1)) changex(mjpw 0 1)
simqi, fd(prval(1)) changex(cntg 0 1)
simqi, fd(prval(1)) changex(dist p5 p95)
simqi, fd(prval(1)) changex(fpceyrs p5 p95)
